
#include "cmsis_os.h"  // CMSIS RTOS header file
#include "Drv_THSensor.h"
#include <string.h>
#include "global.h"
/*----------------------------------------------------------------------------
 *      Thread 1 'Thread_Name': Sample thread
 *---------------------------------------------------------------------------*/

void TemperatureHumidity_Proc(void const *argument)
{
    TransducerInit();   //温湿度传感器初始化
    VariableInit_TH();  //温湿度传感器变量初始化
    while (1)
    {
#if SHT30
        if (SHT30_Read_T_H() == ERR_VALUE)
        {
            g_sVariable.sTemperatureHumidity_inst.u16State |= HARDERR;
            TransducerInit();  //温湿度传感器初始化
        }
        else
        {
            g_sVariable.sTemperatureHumidity_inst.u16State &= ~HARDERR;
        }
        g_sVariable.sTemperatureHumidity_inst.u16Temperature.Value = Tem_Value;  //温度
        g_sVariable.sTemperatureHumidity_inst.u16Humidity.Value    = RH_Value;   //湿度

#else
        g_sVariable.sTemperatureHumidity_inst.u16Temperature.Value = TemperatureHumidity(T_SCMD);   //温度
        g_sVariable.sTemperatureHumidity_inst.u16Humidity.Value    = TemperatureHumidity(RH_SCMD);  //湿度
        g_sVariable.i16Temp = ~g_sVariable.sTemperatureHumidity_inst.u16Temperature.Value;          // TEST
        g_sVariable.i16Temp += 1;
#endif
        osDelay(1000);
    }
}

/*************************************************
  Function:       // VariableInit_TH
  Description:    // 温湿度传感器变量初始化
  Calls:          // ReadTempRh

  Called By:      // TemperatureHumidity_Proc
  Table Accessed: // None
  Table Updated:  // None
  Input:          // None
  Output:         // None
  Return:         // None
  Others:         // None
*************************************************/
void VariableInit_TH(void)
{
    memset(&g_sVariable.sTemperatureHumidity_inst, 0x00, sizeof(sTemperatureHumidity));
}
